home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 792 b | 32 lines | [TEXT/ttxt] |
- --<<<
- -- Kaleida Labs, Inc.
- -- Field Guide to the ScriptX Language
- -- chapter 5, example 2
-
- -- addEmUp takes a variable number of arguments, sums them all
- -- and returns the sum
- function addEmUp #rest numlist -> (
- local sumArgs := 0
- for i in numlist do sumArgs := sumArgs + i
- )
- addEmUp 1 2 3 4 5
- addEmUp 3 4
-
-
- -- joinArray takes a single required array and a variable number
- -- of other arrays. It builds a single array of all the
- -- elements in all its arguments
- function joinArray array1 #rest otherarrays -> (
- for i in otherarrays do addMany array1 i
- return array1
- )
- joinArray #(1,2,3) #(4,5,6)
- joinArray #() #(@angora,@persian) #(@egyptianmau) #(@housecat)
-
-
- function showRest #rest args #key a: b: c:(100) ->
- print args debug
- showRest a:10 b:20 c:30
- showRest a:10
- showRest()
- -->>>